package cn.labbook.bluetooth.entity;

import cn.labbook.bluetooth.common.Tree;
import java.util.Date;
import com.baomidou.mybatisplus.annotation.Version;
import java.io.Serializable;
import java.util.List;
import java.util.Objects;

import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.experimental.Accessors;

/**
 * <p>
 * 
 * </p>
 *
 * @author lonzy
 * @since 2019-03-26
 */
@Data
@EqualsAndHashCode(callSuper = false)
@Accessors(chain = true)
public class Resource implements Serializable, Tree<Resource> {

    private static final long serialVersionUID = 1L;

    private String resourceId;

    /**
     * 权限名称
     */
    private String resourceName;

    /**
     * 权限关键字
     */
    private String resourceKey;

    /**
     * 权限路径
     */
    private String resourceUrl;

    /**
     * 权限类型
     */
    private Integer resourceType;

    private String resourceIcon;

    /**
     * 权限描述
     */
    private String resourceDesc;

    /**
     * 权限有效性
     */
    private Integer resourceValid;

    /**
     * 父级权限ID
     */
    private String parentId;

    /**
     * 创建时间
     */
    private Date createTime;

    /**
     * 版本号
     */
    @Version
    private Integer version;



    /**
     * 子权限
     */
    private transient List<Resource> children;
    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        Resource privilege = (Resource) o;
        return Objects.equals(resourceId, privilege.resourceId);
    }

    @Override
    public int hashCode() {
        return Objects.hash(resourceId);
    }

    @Override
    public String getTreeId() {
        return this.resourceId;
    }

}
